<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>币种管理</title>
	<script type="text/javascript">
		var menu_flag = 'currency';
	</script>
</head>
<body>
	
	<div class="sitemap" id="sitemap">
		当前位置: <a href="${ctx }/order/list">订单管理</a> -&gt; <a href="list"><strong>(${order.orderCode})</strong>账单列表</a> -&gt; 修改费用项
	</div>
	
	<div class="mainoutside mt18">
		<div id="secmainoutside">
			<div class="title">修改收费项目(<font color="red"><c:if test="${orderFee.type==1}">内部账单</c:if><c:if test="${orderFee.type==2}">外部账单</c:if></font>)</div>
			
			<form id="editForm" action="" method="post">
				<input type="hidden" name="id" value="${orderFee.id }"/>
				<table class="mainadd">
					<tbody>
						<tr>
							<td class="name"> 费用名称</td>
							<td class="content">
								<input type="text" class="text" id="fee" name="fee.id"  value="${orderFee.fee.name }" disabled="disabled"/>
								<span class="red"></span>
							</td>
							<td class="content_info">
								<span id="span_fee"></span><span></span>
							</td>
						</tr>
						
						<tr>
							<td class="name"> 单价费用</td>
							<td class="content">
								<input type="text" class="text" id="price" name="price" value="${orderFee.price }" maxlength='32'/>
								<span class="red">*</span>
							</td>
							<td class="content_info">
								<span id="span_price"></span><span></span>
							</td>
						</tr>
						<tr>
							<td class="name"> 数量</td>
							<td class="content">
								<input type="text" class="text" id="units" name="units" value="${orderFee.units }" maxlength='32'/>
								<span class="red">*</span>
							</td>
							<td class="content_info">
								<span id="span_units"></span><span></span>
							</td>
						</tr>
						<tr>
							<td class="name"> 收费币种</td>
							<td class="content">
								<select id="currency" name="currency.id">
									<c:forEach var="currency" items="${currencies}">
										<option value=${currency.id } <c:if test="${currency.id==orderFee.currency.id}">selected="selected"</c:if> >${currency.name }</option>
									</c:forEach>
								</select>
								<span class="red"></span>
							</td>
							<td class="content_info">
								<span id="span_currency"></span><span></span>
							</td>
						</tr>
					</tbody>
					<tfoot>
						<tr>
							<td class="name"></td>
							<td class="btn">
								<input type="submit" class="bigbutsubmit" value="提交"  id="butsubmit_id"/>
								<input type="button" class="bigbutsubmit" onclick="javascript:window.location.href='list';" value="返回"/>
							</td>
						</tr>
					</tfoot>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript">
	$(document).ready(function(){
		$("#editForm").validate({
			rules: {
            "price" : {
                    	number: true,
                    	required: true
        	            },
        	"units" : {
	                    number: true,
	                    required: true
	        	        }          
		},
		messages: {
			"price" : {
            	number: "非法字符，单价必需为数字形式",
            	required: "请填写单价费用"
	        },
			"units" : {
            	number: "非法字符，数量数字形式",
            	required: "请填写数量"
	            }
		},
			errorPlacement: function(error, element){
				$("#span_" + element.attr("id")).html(error).attr("class", "error").addClass('red').next().hide();
			},
			submitHandler: function(form) {
				$("#butsubmit_id").attr("disabled","true");
				setDisabled('input[type="submit"]', window.document)
				$(form).ajaxSubmit({
					 success: function(response){
		        		var data = eval("("+response+")");
		        		if(data.flag==0){
	            			$.alert('修改成功', function(){window.location.href = "list";});
	            		}else{
	            			$.alert('此收费项已添加,请选择别的收费项目');
	                		$("#butsubmit_id").attr("disabled","false");
	            		}
		        		setabled('input[type="submit"]', window.document);
		            }
	            });
			},
			success: function(label){
				var labelparent = label.parent();
				label.parent().html(labelparent.next().html()).attr("class", "valid");
			},
			onkeyup:false
		});
			
	});
	</script>
</body>
</html>